package com.example.administrator.yuejian_15.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;


import com.example.administrator.yuejian_15.R;
import com.example.administrator.yuejian_15.adapter.PxOrderAdapter;
import com.example.administrator.yuejian_15.bean.PxOrderBean;
import com.example.administrator.yuejian_15.listener.ListListener;
import com.example.administrator.yuejian_15.model.GetPxOrderModel;

import java.util.List;

public class GetPxOrderActivity extends BaseActivity implements View.OnClickListener{
    RecyclerView rv_pxor;
    ImageView orpx_fh;
    List<PxOrderBean> items;

    @Override
    void initView() {
        setLayout_file(R.layout.activity_get_px_order);
        rv_pxor = (RecyclerView)findViewById(R.id.rv_pxor);
        orpx_fh = (ImageView)findViewById(R.id.orpx_fh);

        GetPxOrderModel getPxOrderModel = new GetPxOrderModel();
        String uid = getid();
        getPxOrderModel.getPxOrder(uid,pxOrderBeanListListener);
    }

    @Override
    void initEvent() {
        orpx_fh.setOnClickListener(this);

    }

    @Override
    void initDate() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.orpx_fh:
                finish();
                break;
        }
    }
    ListListener<PxOrderBean> pxOrderBeanListListener = new ListListener<PxOrderBean>() {
        @Override
        public void onResponse(List<PxOrderBean> list) {
            LinearLayoutManager linearLayoutManager=new LinearLayoutManager(GetPxOrderActivity.this);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rv_pxor.setLayoutManager(linearLayoutManager);
            items=list;
            PxOrderAdapter pxOrderAdapter=new PxOrderAdapter(GetPxOrderActivity.this,items,R.layout.item);
            rv_pxor.setAdapter(pxOrderAdapter);
            rv_pxor.setItemAnimator(new DefaultItemAnimator());
        }

        @Override
        public void onFail(String msg) {

        }
    };

}
